package com.gxm.练习.多线程.并发包.队列;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @创建人 郭训民
 * @创建时间 2019/11/16
 * @描述
 */
public class 有界Demo {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<String> blockingQueue = new ArrayBlockingQueue(3);
        blockingQueue.offer("张三");
        blockingQueue.offer("李四", 3,TimeUnit.SECONDS);
        blockingQueue.offer("王麻子");
        blockingQueue.offer("小明",3,TimeUnit.SECONDS);
        System.out.println( blockingQueue.poll());
        System.out.println( blockingQueue.poll());
        System.out.println( blockingQueue.poll());
        System.out.println( blockingQueue.poll(3,TimeUnit.SECONDS));

    }
}
